package com.shm.mostRight;

import java.util.Scanner;

public class Main2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s= scanner.nextLine();
        boolean flag=true;
        long ans=0;
        for (int i=0;i<s.length();i++){
            if (s.charAt(i)=='-'&&i==0){
                flag=false;
                continue;
            }
            char c=s.charAt(i);
            if (Character.isLetterOrDigit(c)){
                if (ans<=Long.MAX_VALUE/10){
                    if (Character.isDigit(c)){
                        ans=ans*36+c-'0';
                    }else {
                        ans=ans*36+c-'a'+10;
                    }
                }else {
                    ans=Long.MAX_VALUE;
                    break;
                }
            }else {
                ans=0;
                break;
            }
        }
        if (!flag){
            ans=-ans;
        }
        System.out.println(ans);
    }
}
